package com.tinyspot.concrete.jpa.controller;

import com.tinyspot.concrete.jpa.entity.Order;
import com.tinyspot.concrete.jpa.service.OrderService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Tinyspot
 * @date 2022-12-24 20:17
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderService orderService;

    @GetMapping("/all")
    public List<Order> findAll() {
        return orderService.findAll();
    }

    @GetMapping("/query/{id}")
    public Order findOrderById(@PathVariable Integer id) {
        return orderService.findOrderById(id);
    }

    @PostMapping("/save")
    public String save(Order order) {
        orderService.save(order);
        return "success";
    }

}
